package com.itheima.flowSort;

import org.apache.hadoop.io.WritableComparable;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

public class FlowPojo implements WritableComparable<FlowPojo> {
    private Long upPackNum;
    private Long downPackNum;
    private Long upPayLoad;
    private Long downPayLoad;

    public FlowPojo() {
    }

    public Long getUpPackNum() {
        return upPackNum;
    }

    public void setUpPackNum(Long upPackNum) {
        this.upPackNum = upPackNum;
    }

    public Long getDownPackNum() {
        return downPackNum;
    }

    public void setDownPackNum(Long downPackNum) {
        this.downPackNum = downPackNum;
    }

    public Long getUpPayLoad() {
        return upPayLoad;
    }

    public void setUpPayLoad(Long upPayLoad) {
        this.upPayLoad = upPayLoad;
    }

    public Long getDownPayLoad() {
        return downPayLoad;
    }

    public void setDownPayLoad(Long downPayLoad) {
        this.downPayLoad = downPayLoad;
    }

    @Override
    public String toString() {
        return upPackNum+"\t"+downPackNum+"\t"+upPayLoad+"\t"+downPayLoad;
    }

    @Override
    public void write(DataOutput dataOutput) throws IOException {
        dataOutput.writeLong(upPackNum);
        dataOutput.writeLong(downPackNum);
        dataOutput.writeLong(upPayLoad);
        dataOutput.writeLong(downPayLoad);
    }

    @Override
    public void readFields(DataInput dataInput) throws IOException {
        this.upPackNum=dataInput.readLong();
        this.downPackNum=dataInput.readLong();
        this.upPayLoad=dataInput.readLong();
        this.downPayLoad=dataInput.readLong();
    }

    @Override
    public int compareTo(FlowPojo o) {
        int i = o.upPackNum.compareTo(this.upPackNum);
        return i;
    }


}
